
package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MeowSalesOrderDetails;
import com.ruoyi.system.service.IMeowSalesOrderDetailsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

@Controller
@RequestMapping("/system/sales-details")
public class MeowSalesOrderDetailsController extends BaseController
{
    private String prefix = "system/sales-details";

    @Autowired
    private IMeowSalesOrderDetailsService meowSalesOrderDetailsService;

    @RequiresPermissions("system:sales-details:view")
    @GetMapping()
    public String details()
    {
        return prefix + "/details";
    }

    @RequiresPermissions("system:sales-details:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MeowSalesOrderDetails meowSalesOrderDetails)
    {
        startPage();
        List<MeowSalesOrderDetails> list = meowSalesOrderDetailsService.selectMeowSalesOrderDetailsList(meowSalesOrderDetails);
        return getDataTable(list);
    }

    @RequiresPermissions("system:sales-details:export")
    @Log(title = "销售订单明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MeowSalesOrderDetails meowSalesOrderDetails)
    {
        List<MeowSalesOrderDetails> list = meowSalesOrderDetailsService.selectMeowSalesOrderDetailsList(meowSalesOrderDetails);
        ExcelUtil<MeowSalesOrderDetails> util = new ExcelUtil<MeowSalesOrderDetails>(MeowSalesOrderDetails.class);
        return util.exportExcel(list, "销售订单明细数据");
    }

    @RequiresPermissions("system:sales-details:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    @RequiresPermissions("system:sales-details:add")
    @Log(title = "销售订单明细", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MeowSalesOrderDetails meowSalesOrderDetails)
    {
        return toAjax(meowSalesOrderDetailsService.insertMeowSalesOrderDetails(meowSalesOrderDetails));
    }

    @RequiresPermissions("system:sales-details:edit")
    @GetMapping("/edit/{detailId}")
    public String edit(@PathVariable("detailId") String detailId, ModelMap mmap)
    {
        MeowSalesOrderDetails meowSalesOrderDetails = meowSalesOrderDetailsService.selectMeowSalesOrderDetailsByDetailId(detailId);
        mmap.put("meowSalesOrderDetails", meowSalesOrderDetails);
        return prefix + "/edit";
    }

    @RequiresPermissions("system:sales-details:edit")
    @Log(title = "销售订单明细", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MeowSalesOrderDetails meowSalesOrderDetails)
    {
        return toAjax(meowSalesOrderDetailsService.updateMeowSalesOrderDetails(meowSalesOrderDetails));
    }

    @RequiresPermissions("system:sales-details:remove")
    @Log(title = "销售订单明细", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(meowSalesOrderDetailsService.deleteMeowSalesOrderDetailsByDetailIds(ids));
    }
}
